USE [Habilitaciones]
GO
/****** Object:  ForeignKey [FK_Localidades_Municipios]    Script Date: 11/21/2011 07:20:58 ******/
ALTER TABLE [dbo].[Localidades] DROP CONSTRAINT [FK_Localidades_Municipios]
GO
/****** Object:  ForeignKey [FK_Ordenes_Estados]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Estados]
GO
/****** Object:  ForeignKey [FK_Ordenes_Pagos]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Pagos]
GO
/****** Object:  ForeignKey [FK_Ordenes_Rubros]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Rubros]
GO
/****** Object:  ForeignKey [FK_Ordenes_Vehiculos]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Vehiculos]
GO
/****** Object:  ForeignKey [FK_OrdenesPersonas_Ordenes]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas] DROP CONSTRAINT [FK_OrdenesPersonas_Ordenes]
GO
/****** Object:  ForeignKey [FK_OrdenesPersonas_Personas]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas] DROP CONSTRAINT [FK_OrdenesPersonas_Personas]
GO
/****** Object:  ForeignKey [FK_OrdenesPersonas_Roles]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas] DROP CONSTRAINT [FK_OrdenesPersonas_Roles]
GO
/****** Object:  ForeignKey [FK_Personas_Localidades]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Personas] DROP CONSTRAINT [FK_Personas_Localidades]
GO
/****** Object:  ForeignKey [FK_Personas_TiposDocumento]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Personas] DROP CONSTRAINT [FK_Personas_TiposDocumento]
GO
/****** Object:  Table [habilitaciones].[OrdenesPersonas]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas] DROP CONSTRAINT [FK_OrdenesPersonas_Ordenes]
GO
ALTER TABLE [habilitaciones].[OrdenesPersonas] DROP CONSTRAINT [FK_OrdenesPersonas_Personas]
GO
ALTER TABLE [habilitaciones].[OrdenesPersonas] DROP CONSTRAINT [FK_OrdenesPersonas_Roles]
GO
DROP TABLE [habilitaciones].[OrdenesPersonas]
GO
/****** Object:  Table [habilitaciones].[Personas]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Personas] DROP CONSTRAINT [FK_Personas_Localidades]
GO
ALTER TABLE [habilitaciones].[Personas] DROP CONSTRAINT [FK_Personas_TiposDocumento]
GO
DROP TABLE [habilitaciones].[Personas]
GO
/****** Object:  Table [dbo].[Localidades]    Script Date: 11/21/2011 07:20:58 ******/
ALTER TABLE [dbo].[Localidades] DROP CONSTRAINT [FK_Localidades_Municipios]
GO
DROP TABLE [dbo].[Localidades]
GO
/****** Object:  Table [habilitaciones].[Ordenes]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Estados]
GO
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Pagos]
GO
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Rubros]
GO
ALTER TABLE [habilitaciones].[Ordenes] DROP CONSTRAINT [FK_Ordenes_Vehiculos]
GO
DROP TABLE [habilitaciones].[Ordenes]
GO
/****** Object:  Table [habilitaciones].[Estados]    Script Date: 11/21/2011 07:20:59 ******/
DROP TABLE [habilitaciones].[Estados]
GO
/****** Object:  Table [dbo].[Municipios]    Script Date: 11/21/2011 07:20:58 ******/
DROP TABLE [dbo].[Municipios]
GO
/****** Object:  Table [habilitaciones].[Roles]    Script Date: 11/21/2011 07:20:59 ******/
DROP TABLE [habilitaciones].[Roles]
GO
/****** Object:  Table [habilitaciones].[Rubros]    Script Date: 11/21/2011 07:21:00 ******/
DROP TABLE [habilitaciones].[Rubros]
GO
/****** Object:  Table [dbo].[TiposDocumento]    Script Date: 11/21/2011 07:20:59 ******/
DROP TABLE [dbo].[TiposDocumento]
GO
/****** Object:  Table [habilitaciones].[Vehiculos]    Script Date: 11/21/2011 07:21:00 ******/
DROP TABLE [habilitaciones].[Vehiculos]
GO
/****** Object:  Table [habilitaciones].[Pagos]    Script Date: 11/21/2011 07:20:59 ******/
DROP TABLE [habilitaciones].[Pagos]
GO
/****** Object:  Table [habilitaciones].[Pagos]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Pagos](
	[IdPago] [int] IDENTITY(1,1) NOT NULL,
	[TransaccionNro] [int] NOT NULL,
	[FechaPago] [date] NOT NULL,
	[UserCrea] [varchar](50) NOT NULL,
	[FechaCrea] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_Pagos] PRIMARY KEY CLUSTERED 
(
	[IdPago] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[Vehiculos]    Script Date: 11/21/2011 07:21:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Vehiculos](
	[IdVehiculo] [int] IDENTITY(1,1) NOT NULL,
	[Dominio] [varchar](6) NOT NULL,
	[Marca] [varchar](50) NOT NULL,
	[ModeloAnio] [smallint] NOT NULL,
	[InternoNro] [varchar](50) NULL,
	[MotorNro] [varchar](50) NULL,
	[RelojNro] [varchar](50) NULL,
	[PolizaSegNro] [varchar](50) NULL,
	[PolizaSegCompania] [varchar](50) NULL,
	[PolizaSegVencimiento] [date] NULL,
	[UserCrea] [varchar](50) NOT NULL,
	[FechaCrea] [smalldatetime] NOT NULL,
	[UserModif] [varchar](50) NOT NULL,
	[FechaModif] [smalldatetime] NOT NULL,
	[Tipo] [varchar](50) NULL,
	[Modelo] [varchar](50) NULL,
 CONSTRAINT [PK_Vehiculos] PRIMARY KEY CLUSTERED 
(
	[IdVehiculo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TiposDocumento]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TiposDocumento](
	[IdTipoDocumento] [tinyint] IDENTITY(1,1) NOT NULL,
	[TipoDocumento] [varchar](10) NOT NULL,
 CONSTRAINT [PK_TiposDocumento] PRIMARY KEY CLUSTERED 
(
	[IdTipoDocumento] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[Rubros]    Script Date: 11/21/2011 07:21:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Rubros](
	[IdRubro] [tinyint] NOT NULL,
	[Rubro] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Rubros] PRIMARY KEY CLUSTERED 
(
	[IdRubro] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[Roles]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Roles](
	[IdRol] [tinyint] IDENTITY(1,1) NOT NULL,
	[Rol] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED 
(
	[IdRol] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Municipios]    Script Date: 11/21/2011 07:20:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Municipios](
	[IdMunicipio] [int] NOT NULL,
	[RefProvincia] [tinyint] IDENTITY(1,1) NOT NULL,
	[Municipio] [varchar](255) NOT NULL,
	[Activo] [bit] NOT NULL,
 CONSTRAINT [PK_Municipios] PRIMARY KEY CLUSTERED 
(
	[IdMunicipio] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[Estados]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Estados](
	[IdEstado] [tinyint] IDENTITY(1,1) NOT NULL,
	[Estado] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Estados] PRIMARY KEY CLUSTERED 
(
	[IdEstado] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[Ordenes]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Ordenes](
	[IdOrden] [int] IDENTITY(1,1) NOT NULL,
	[FechaInicioTramite] [date] NOT NULL,
	[RefRubro] [tinyint] NOT NULL,
	[RefVehiculo] [int] NOT NULL,
	[Expediente] [varchar](50) NULL,
	[NroHabilitacion] [int] NULL,
	[FechaHabilitacion] [date] NULL,
	[RefEstado] [tinyint] NOT NULL,
	[RefPago] [int] NULL,
	[UserCrea] [varchar](50) NOT NULL,
	[FechaCrea] [smalldatetime] NOT NULL,
	[UserModif] [varchar](50) NOT NULL,
	[FechaModif] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_habilitaciones.Ordenes] PRIMARY KEY CLUSTERED 
(
	[IdOrden] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Localidades]    Script Date: 11/21/2011 07:20:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Localidades](
	[IdLocalidad] [int] IDENTITY(1,1) NOT NULL,
	[RefMunicipio] [int] NOT NULL,
	[Localidad] [varchar](255) NOT NULL,
	[CodigoPostal] [int] NULL,
	[Activo] [bit] NOT NULL,
 CONSTRAINT [PK_Localidades] PRIMARY KEY CLUSTERED 
(
	[IdLocalidad] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[Personas]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [habilitaciones].[Personas](
	[IdPersona] [int] NOT NULL,
	[RefTipoDocumento] [tinyint] NOT NULL,
	[NroDocumento] [int] NOT NULL,
	[Sexo] [char](1) NOT NULL,
	[Apellido] [varchar](255) NOT NULL,
	[FechaNacimiento] [date] NULL,
	[Calle] [varchar](255) NOT NULL,
	[NroPuerta] [varchar](10) NOT NULL,
	[OtrasReferencias] [varchar](255) NULL,
	[RefLocalidad] [int] NOT NULL,
	[RegistroNro] [int] NULL,
	[ExpedidoPor] [varchar](255) NULL,
	[LibretaSanitariaNro] [int] NULL,
	[Vencimiento] [date] NULL,
	[UrlFoto] [varchar](255) NULL,
	[UrlHuella] [varchar](255) NULL,
	[UrlFirma] [varchar](255) NULL,
	[UserCrea] [varchar](50) NOT NULL,
	[FechaCrea] [smalldatetime] NOT NULL,
	[UserModif] [varchar](50) NOT NULL,
	[FechaModif] [smalldatetime] NOT NULL,
	[Nombre] [varchar](50) NULL,
 CONSTRAINT [PK_Persona] PRIMARY KEY CLUSTERED 
(
	[IdPersona] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [habilitaciones].[OrdenesPersonas]    Script Date: 11/21/2011 07:20:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [habilitaciones].[OrdenesPersonas](
	[IdOrdenPersona] [int] IDENTITY(1,1) NOT NULL,
	[RefOrden] [int] NOT NULL,
	[RefPersona] [int] NOT NULL,
	[RefRol] [tinyint] NOT NULL,
 CONSTRAINT [PK_OrdenesPersonas] PRIMARY KEY CLUSTERED 
(
	[IdOrdenPersona] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Localidades_Municipios]    Script Date: 11/21/2011 07:20:58 ******/
ALTER TABLE [dbo].[Localidades]  WITH CHECK ADD  CONSTRAINT [FK_Localidades_Municipios] FOREIGN KEY([RefMunicipio])
REFERENCES [dbo].[Municipios] ([IdMunicipio])
GO
ALTER TABLE [dbo].[Localidades] CHECK CONSTRAINT [FK_Localidades_Municipios]
GO
/****** Object:  ForeignKey [FK_Ordenes_Estados]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes]  WITH CHECK ADD  CONSTRAINT [FK_Ordenes_Estados] FOREIGN KEY([RefEstado])
REFERENCES [habilitaciones].[Estados] ([IdEstado])
GO
ALTER TABLE [habilitaciones].[Ordenes] CHECK CONSTRAINT [FK_Ordenes_Estados]
GO
/****** Object:  ForeignKey [FK_Ordenes_Pagos]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes]  WITH CHECK ADD  CONSTRAINT [FK_Ordenes_Pagos] FOREIGN KEY([RefPago])
REFERENCES [habilitaciones].[Pagos] ([IdPago])
GO
ALTER TABLE [habilitaciones].[Ordenes] CHECK CONSTRAINT [FK_Ordenes_Pagos]
GO
/****** Object:  ForeignKey [FK_Ordenes_Rubros]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes]  WITH CHECK ADD  CONSTRAINT [FK_Ordenes_Rubros] FOREIGN KEY([RefRubro])
REFERENCES [habilitaciones].[Rubros] ([IdRubro])
GO
ALTER TABLE [habilitaciones].[Ordenes] CHECK CONSTRAINT [FK_Ordenes_Rubros]
GO
/****** Object:  ForeignKey [FK_Ordenes_Vehiculos]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Ordenes]  WITH CHECK ADD  CONSTRAINT [FK_Ordenes_Vehiculos] FOREIGN KEY([RefVehiculo])
REFERENCES [habilitaciones].[Vehiculos] ([IdVehiculo])
GO
ALTER TABLE [habilitaciones].[Ordenes] CHECK CONSTRAINT [FK_Ordenes_Vehiculos]
GO
/****** Object:  ForeignKey [FK_OrdenesPersonas_Ordenes]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas]  WITH CHECK ADD  CONSTRAINT [FK_OrdenesPersonas_Ordenes] FOREIGN KEY([RefOrden])
REFERENCES [habilitaciones].[Ordenes] ([IdOrden])
GO
ALTER TABLE [habilitaciones].[OrdenesPersonas] CHECK CONSTRAINT [FK_OrdenesPersonas_Ordenes]
GO
/****** Object:  ForeignKey [FK_OrdenesPersonas_Personas]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas]  WITH CHECK ADD  CONSTRAINT [FK_OrdenesPersonas_Personas] FOREIGN KEY([RefPersona])
REFERENCES [habilitaciones].[Personas] ([IdPersona])
GO
ALTER TABLE [habilitaciones].[OrdenesPersonas] CHECK CONSTRAINT [FK_OrdenesPersonas_Personas]
GO
/****** Object:  ForeignKey [FK_OrdenesPersonas_Roles]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[OrdenesPersonas]  WITH CHECK ADD  CONSTRAINT [FK_OrdenesPersonas_Roles] FOREIGN KEY([RefRol])
REFERENCES [habilitaciones].[Roles] ([IdRol])
GO
ALTER TABLE [habilitaciones].[OrdenesPersonas] CHECK CONSTRAINT [FK_OrdenesPersonas_Roles]
GO
/****** Object:  ForeignKey [FK_Personas_Localidades]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Personas]  WITH CHECK ADD  CONSTRAINT [FK_Personas_Localidades] FOREIGN KEY([RefLocalidad])
REFERENCES [dbo].[Localidades] ([IdLocalidad])
GO
ALTER TABLE [habilitaciones].[Personas] CHECK CONSTRAINT [FK_Personas_Localidades]
GO
/****** Object:  ForeignKey [FK_Personas_TiposDocumento]    Script Date: 11/21/2011 07:20:59 ******/
ALTER TABLE [habilitaciones].[Personas]  WITH CHECK ADD  CONSTRAINT [FK_Personas_TiposDocumento] FOREIGN KEY([RefTipoDocumento])
REFERENCES [dbo].[TiposDocumento] ([IdTipoDocumento])
GO
ALTER TABLE [habilitaciones].[Personas] CHECK CONSTRAINT [FK_Personas_TiposDocumento]
GO
